﻿using System.Text;
using System.Globalization;

namespace RapidSpider.DownloadAgents
{
    public partial class DownloadAgent
    {
        #region Methods
        public static string URLEncode(string theString)
        {
            StringBuilder theData = new StringBuilder();

            foreach (char thisChar in theString.ToCharArray())
            {
                theData.Append("%");
                theData.AppendFormat(
                    CultureInfo.CurrentCulture,
                    "{0:X2}",
                    (int)thisChar);
            }

            return theData.ToString();
        }
        #endregion
    }
}
